package com.xr.hr.personnel;

import java.util.Date;

import com.xr.common.CommUtil;
import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;

/**
 * onOffModifyViewModel
 */
public class onOffModifyViewModel extends DefaultViewModel {
	protected void doUpdateData(ParameterSet parameters,
			ParameterSet outParameters) throws Exception {
		DBStatement dbs = new DBStatement();
		Dataset dsEmp = getDataset("datasetEmp");
		Dataset dsOos = getDataset("datasetOos");
		Dataset dsEcfiWfCi = getDataset("datasetEcfi");
		Dataset dsEcfiWfCiHis = getDataset("datasetEcfiHis");
		dsOos.setString("MODIFY_ID", CommUtil.getEmployeeId());
		dsOos.setDate("MODIFY_DATE", new java.sql.Date(new Date().getTime()));
		
		CommUtil.dbsUpdateData(dbs, dsEmp, "ORG_EMPLOYEE","EMPLOYEE_ID", "");
		CommUtil.dbsUpdateData(dbs, dsOos, "ORG_ONOFF_STATION","ONOFF_STATION_ID", "");
		
		RecordIterator ri = dsEcfiWfCi.recordIterator();
		ri.setVisibility(Dataset.FILTER_CHANGED);
		while (ri.hasNext()) {
		  Record record = ri.nextRecord();
		  record.setString("MODIFY_ID", CommUtil.getEmployeeId());
		  record.setDate("MODIFY_DATE", new java.sql.Date(new Date().getTime()));
		}
		
		CommUtil.dbsUpdateData(dbs, dsEcfiWfCi, "WF_ECFI","ECFI_ID", "");
		
		ri = dsEcfiWfCiHis.recordIterator();
		ri.setVisibility(Dataset.FILTER_CHANGED);
		while (ri.hasNext()) {
		  Record record = ri.nextRecord();
		  record.setString("MODIFY_ID", CommUtil.getEmployeeId());
		  record.setDate("MODIFY_DATE", new java.sql.Date(new Date().getTime()));
		}
		
		CommUtil.dbsUpdateData(dbs, dsEcfiWfCiHis, "WF_ECFI","ECFI_ID", "");
		dbs.close();
		
		//super.doUpdateData(parameters, outParameters);
	}
	
	public void batchEmpOos_submit(ParameterSet parameters,ParameterSet outParameters) throws Exception {
		DBStatement dbs = new DBStatement();
		Dataset dsOos = getDataset("datasetEmpOos");
		
		
		CommUtil.dbsUpdateData(dbs, dsOos, "org_employee","employee_id");
		super.doUpdateData(parameters, outParameters);
		dbs.close();
	}
}
